﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using FreeSql;
using Server;

namespace Server
{

    public class Servers
    {
        public event Action<string,float> RecordDoing;
        public static IFreeSql DB = new FreeSqlBuilder()
                                .UseConnectionString(DataType.Sqlite, $@"Data Source={AppDomain.CurrentDomain.BaseDirectory}DB.db;version=3;")
                                .UseAutoSyncStructure(false)
                                .Build();
        //public static IFreeSql DB = new FreeSqlBuilder()
        //                        .UseConnectionString(DataType.Sqlite, $@"Data Source=D:\DB.db;version=3;")
        //                        .UseAutoSyncStructure(false)
        //                        .Build();

        public static event Action<string, string> PlcTagValChange;
        /// <summary>
        /// 启动服务
        /// </summary>
        public void Start()
        {
            recordServer = new RecordServer();
            recordServer.Start();
            recordServer.RecordDoingEvent += OnRecordDoing;
        }
        private RecordServer recordServer;

        private  void OnRecordDoing(string bearingno,float oilnum)
        {
            RecordDoing?.Invoke(bearingno,oilnum);
        }
    }
}
